package com.hsp.demo_08_object_test;

public class Demo_04 {
    public static void main(String[] args) {
        /*
        通过继承实现员工工资核算打印功能：
            父类：员工类
            子类：部门经理类、普通员工类
            1、部门经理工资 = 1000 + 单日工资*天数*等级（1.2）。
            2、普通员工工资 = 单日工资 * 天数 * 等级（1.0）。
            3、员工属性：姓名，单日工资，工作天数。
            4、员工方法：打印工资。
            5、普通员工和部门经济都是员工子类，需重写打印工资方法。
            6、定义并初始化普通员工对象，调用打印工资方法，输入工资，定义并初始化部门经理对象，
         调用打印工资方法输入工资。 （疑问：输出工资才对吧。）
         */
        Employee e1  = new Manager("小王", 200, 25, 1.2);
        e1.showSalary();
    }
}

/**
 * 部门经理类
 */
class Manager extends Employee{

    //级别
    private double level;

   public Manager(){}

   public Manager(String name, double salary, double workDay, double level){
       super(name, salary, workDay);
       this.level = level;
   }

    @Override
    public void showSalary() {
        double monthSalary =1000 + super.getSalary() * super.getWorkDay() * level;
        System.out.println("当月应发工资：" + monthSalary);
    }
}

/**
 * 员工类
 */
class Employee{
    //员工姓名
    private String name;
    //单日工资
    private double salary;
    //工作天数
    private double workDay;

    public Employee(){}

    public Employee(String name, double salary, double workDay) {
        this.name = name;
        this.salary = salary;
        this.workDay = workDay;
    }

    public void showSalary(){
        double monthSalary = salary * workDay;
        System.out.println("当月应发工资：" + monthSalary);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public double getWorkDay() {
        return workDay;
    }

    public void setWorkDay(double workDay) {
        this.workDay = workDay;
    }
}